package com.shire.order.controller;

import com.api.common.entity.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private RestTemplate restTemplate;


    @GetMapping("/getPaymentById/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Integer id){


        String BASHE_URL = "http://127.0.0.1:8001/payment/getPaymentById/1";

        ResponseEntity<CommonResult> entity = restTemplate.getForEntity(BASHE_URL , CommonResult.class);

        CommonResult commonResult = entity.getBody();


        if (commonResult.getResponeData() != null){

            return new CommonResult(200,"Order响应成功",commonResult.getResponeData());
        }else {

            return new CommonResult(404,"Order响应失败");
        }
    }
}
